﻿app.controller('subcriberController', function ($scope, $http, $timeout) {

    $timeout(function () {
        
        var popstatus = localStorage.getItem("PStatus");
        if (popstatus == null) {
            $("#myModal").modal({ backdrop: 'static' });
        }
        else if(popstatus == "ASKL")
        {
        }
        else if(popstatus == "NSKL")
        {
        }
        else if(popstatus == "EIX")
        {
        }
        else if(popstatus == "ISUS")
        {
        }
    }, 2000);

    $scope.Subcribe = function () {
        $scope.btnstatus = true;
        var url = "Home/SaveSubcriber";
        $http.post(url, $scope.sub).success(function (data) {
            $scope.btnstatus = false;
            $scope.result = data;
            $scope.sub = null;
            localStorage.setItem("PStatus", data);
            $timeout(function () {
                $("#myModal").modal('hide');
            }, 3000);
        });
    }

    $scope.neverask = function () {
        localStorage.setItem("PStatus", "NASK");
        $("#myModal").modal('hide');
    }

    $scope.askmelatter = function () {
        localStorage.setItem("PStatus", "ASKL");
        $("#myModal").modal('hide');
    }

});